package programmercarl.动态规划.C41;

class Solution {
    public static int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
        }
        for (int i = 1; i < nums.length; i++) {
            //对于每个i，从0到i-1,判断是否递增的，是就去较大值
            for (int j = 0; j < i; j++) {
                if(nums[i]>nums[j]){//挨个检测会漏掉
                    dp[i]=Math.max(dp[i],dp[j]+1);//因为满足了要加进去，不然就是dp[i]
                }
            }
        }
        int max = 0;
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(max,dp[i]);
        }
        return max;
    }

    public static void main(String[] args) {
        int length = lengthOfLIS(new int[]{10, 9, 2, 5, 3, 7, 101, 18});
        System.out.println(length);
    }


}